package model;

import entities.Shift;
import java.io.Serializable;
import java.util.ArrayList;
import javax.swing.AbstractListModel;
import javax.swing.MutableComboBoxModel;

public class ViewShiftComboBoxModel extends AbstractListModel implements MutableComboBoxModel, Serializable {

    ArrayList<Shift> list;
    Shift selectedItem;

    public ViewShiftComboBoxModel(ArrayList<Shift> list) {
        this.list = list;
    }

    @Override
    public int getSize() {
        return list.size();
    }

    @Override
    public Object getElementAt(int index) {
        return list.get(index);
    }

    @Override
    public void addElement(Object item) {
        list.add((Shift) item);
    }

    @Override
    public void removeElement(Object obj) {
        list.remove(obj);
    }

    @Override
    public void insertElementAt(Object item, int index) {
        list.add(index, (Shift) item);
    }

    @Override
    public void removeElementAt(int index) {
        list.remove(index);
    }

    @Override
    public void setSelectedItem(Object anItem) {
        selectedItem = (Shift) anItem;
    }

    @Override
    public Object getSelectedItem() {
        return selectedItem;
    }
}
